import Vue from 'vue'
import VueRouter from 'vue-router'
import About from '../views/About.vue'
import Register from '../views/Register.vue'
import Login from '../views/Login.vue'
import NotFound from '../views/404.vue'
import Home from '../views/Home.vue'
import InfoShow from '../views/InfoShow.vue'
import FoundList from '../views/FoundList.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/about'
    // name: 'Home',
    // component: Home
  },
  {
    path: '/about',
    name: 'About',
    component: () => import('../views/About.vue'),
    children: [
      {path: '', component: Home},
      {path: '/home', name: 'home', component: Home},
      {path: '/infoshow', name: 'infosuhow', component: InfoShow},
      {path: '/foundlist', name: 'foundlist', component: FoundList}
    ]
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '*',
    name: '/404',
    component: NotFound
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// router.beforeEach((to, from, next) => {
//   const isLogin = localStorage.eleToken ? true : false;
//   if(to.path == '/login' || to.path == '/register'){
//     next();
//   }else{
//     isLogin ? next() : next('/login');
//   }
// })

export default router
